package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.ICustomsManagementDao;
import com.act.domain.CustomsManagement;
import com.act.dto.PagerDTO;
import com.act.service.api.ICustomsManagementService;
import com.act.vo.PagerVo;

@Service
public class CustomsManagementServiceImpl implements ICustomsManagementService{
	
	@Resource
	ICustomsManagementDao customsManagementDao;

	@Override
	public void add(CustomsManagement customsManagement) {
		// TODO Auto-generated method stub
		customsManagementDao.add(customsManagement);
	}

	@Override
	public void delete(int id) {
		// TODO Auto-generated method stub
		customsManagementDao.delete(id);
	}

	@Override
	public void update(CustomsManagement customsManagement) {
		// TODO Auto-generated method stub
		customsManagementDao.update(customsManagement);
	}

	@Override
	public PagerVo<Map> getAllByTypeOrPayyee(@Param("type")String type,@Param("payee")String payee,@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = customsManagementDao.getCounts();
		List<Map> list = customsManagementDao.getAllByTypeOrPayyee(type, payee,startIndex,endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);
		
		return pagerVo;
	}

	@Override
	public CustomsManagement getCustomsById(int id) {
		return customsManagementDao.getCustomsById(id);
	}

	@Override
	public PagerVo<Map> getAll(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		List<Map> list = customsManagementDao.getAll(startIndex, endIndex);
		int totalCounts = customsManagementDao.getCounts();
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);
		
		return pagerVo;
	}

}
